package com.spring.ioc.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

//@RestController
@Controller
@ResponseBody
@RequestMapping("/prop")
public class PropertiesController {
    @Value("${my.Key}")
    private String myKey;

    @Value("${my.Key2}")
    private String myKey2;

    @RequestMapping("/read")
    public String readValues() {
        return "读取配置文件my.Key: " + myKey;
    }

    @PostConstruct
    public void init() {
        System.out.println("myKey2: " + myKey2);
    }
}
